package microarray;

import java.io.*;
import java.net.*;

public abstract class MicroArrayElement
{

	protected MicroArrayCrawler parent;

	protected URL url;
	protected String id;
	private final String dataUrlString = "http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=ID_HERE&targ=self&view=data&form=text";
	private final String generalUrlString = "http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=ID_HERE&targ=self&form=text";

	public URL getDataURL()
	{
		try
		{
			return new URL(dataUrlString.replace("ID_HERE", id));
		} catch (IOException e)
		{
			System.out.println("Error updating URL " + e);
			return null;
		}
	}

	public URL getGeneralURL()
	{
		try
		{
			return new URL(generalUrlString.replace("ID_HERE", id));
		} catch (IOException e)
		{
			System.out.println("Error updating URL " + e);
			return null;
		}
	}

	public abstract String getDir();

	public abstract void scrapeAndRecord() throws IOException;

	// public abstract void scrape() throws IOException;
	public abstract void build() throws IOException;

	public MicroArrayElement(String id) throws IOException
	{
		this.id = id;
	}

	protected void printDebug(String str)
	{
		if (parent.isDebug())
			System.out.println(str);
	}

	public String getID()
	{
		return id;
	}
}